enum Permission {
  Read = 1,
  Write = 2,
  Create = 4,
  Delete = 8,
}

// 新增：位运算 |： 相同为0，不同为1
let ReadAndWrite: Permission = Permission.Read | Permission.Write;

// 判断 &: 相同为相同值，不同为0
function hasPermission(target: Permission, per: Permission) {
  return (target & per) === per;
}

console.log(hasPermission(ReadAndWrite, Permission.Delete));

// 删除：^ 相同去0， 不同去1
ReadAndWrite = ReadAndWrite ^ Permission.Write;
console.log(hasPermission(ReadAndWrite, Permission.Write));
